package com.xlhj.dynamic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xlhj.dynamic.dto.UserReqDto;
import com.xlhj.dynamic.mapper.SysUserInfoMapper;
import com.xlhj.dynamic.model.SysUserInfo;
import com.xlhj.dynamic.service.SysUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: caijliu
 * @description: SysUserInfoServiceImpl
 * @data: 06/08/2021 9:09
 */
@Service
public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUserInfo> implements SysUserInfoService {

    @Autowired
    private SysUserInfoMapper userInfoMapper;

    @Override
    public IPage<SysUserInfo> getPageUserList(UserReqDto reqDto) {
        LambdaQueryWrapper<SysUserInfo> queryWrapper = new LambdaQueryWrapper<>();
        if (null != reqDto.getUserName()) {
            queryWrapper.eq(SysUserInfo::getUserName, reqDto.getUserName());
        }
        if (null != reqDto.getAge()) {
            queryWrapper.eq(SysUserInfo::getAge, reqDto.getAge());
        }
        if (null != reqDto.getSex()) {
            queryWrapper.eq(SysUserInfo::getSex, reqDto.getSex());
        }
        if (null != reqDto.getStatus()) {
            queryWrapper.eq(SysUserInfo::getStatus, reqDto.getStatus());
        }
        IPage<SysUserInfo> pageData = new Page<>(reqDto.getPageNum(), reqDto.getPageSize());
        List<SysUserInfo> userInfoList = (List<SysUserInfo>) userInfoMapper.selectPage(pageData, queryWrapper);
        pageData.setRecords(userInfoList);
        return pageData;
    }




















}
